package com.dbuil.bleshoes.ui.fragment.childfragment;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.LogUtils;
import com.dbuil.bleshoes.R;
import com.dbuil.bleshoes.base.BasePagerFragment;
import com.dbuil.bleshoes.ui.activity.HomeActivity;
import com.dbuil.bleshoes.utils.banner.BannerBean;
import com.dbuil.bleshoes.utils.banner.XBannerUtils;
import com.stx.xhb.androidx.XBanner;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class TuijianFragment extends BasePagerFragment {
    @BindView(R.id.xbanner_view)
    XBanner xbannerView;
    @BindView(R.id.ll_points)
    LinearLayout llPoints;

    @Override
    protected View getLayoutId() {
        View inflate = LayoutInflater.from(context).inflate(R.layout.fragment_tuijian, null);
        return inflate;

    }

    @Override
    protected void initView() {
    }


    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            //页面可见
            LogUtils.i("推荐页面==可见");
        } else {
            //页面不可见
            LogUtils.i("推荐页面==不可见");
        }
    }

    @Override
    protected void loadData() {
        LogUtils.i("推荐页面");
        initBanner();
    }

    private void initBanner() {
        List<BannerBean> bannerdata = new ArrayList<>();
        for (String s : getUrl().subList(6, 11)) {
            bannerdata.add(new BannerBean(s, "", ""));
        }
        XBannerUtils.indicatorBanner(context, xbannerView, bannerdata, true, llPoints);
        XBannerUtils.setOnBannerItemClick((bannerBean, position) -> ActivityUtils.startActivity(HomeActivity.class));
    }

}
